package com.jic.order.impl;

import com.jic.common.base.vo.Page;
import com.jic.order.entity.OrderSplitCondition;
import com.jic.order.mapper.OrderSplitConditionMapper;
import com.jic.common.base.vo.PageResult;
import com.jic.order.service.OrderSplitConditionService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 订单拆分规则匹配条件表
 *
 * @author :
 * @version : v1.0.0
 * @email :
 * @since : 2020-02-26 10:57:52
 */
@Service
public class OrderSplitConditionServiceImpl implements OrderSplitConditionService {

	@Autowired
	private OrderSplitConditionMapper orderSplitConditionMapper;

	@Override
	public long insert(OrderSplitCondition orderSplitCondition) {
		long flag = orderSplitConditionMapper.insert(orderSplitCondition);
		return flag;
	}

	@Override
	public long delete(Long id) {
		return orderSplitConditionMapper.delete(id);
	}

	@Override
	public long update(OrderSplitCondition orderSplitCondition) {
		return orderSplitConditionMapper.update(orderSplitCondition);
	}

	@Override
	public OrderSplitCondition queryByPrimaryKey(Long id) {
		return orderSplitConditionMapper.queryByPrimaryKey(id);
	}

	@Override
	public List<OrderSplitCondition> query(OrderSplitCondition orderSplitCondition) {
		return orderSplitConditionMapper.query(orderSplitCondition);
	}

	@Override
	public PageResult<OrderSplitCondition> queryPage(OrderSplitCondition orderSplitCondition, Page pageQuery) {
		//计算下标
		int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
		List<OrderSplitCondition> list = orderSplitConditionMapper.queryPage(startIndex, pageQuery.getLimit(), orderSplitCondition);
		long count = orderSplitConditionMapper.queryPageCount(orderSplitCondition);
		PageResult pageResult = new PageResult();
		pageResult.setRows(list);
		pageResult.setTotal(count);
		return pageResult;
	}
}